<template>
  <div class="app-container">
    <el-form ref="form" :model="teacher" label-width="120px">
      <el-form-item label="教师名">
        <el-input v-model="teacher.tname"/>
      </el-form-item>
      <el-form-item label="性别">
        <el-input v-model="teacher.sex"/>
      </el-form-item>
      <el-form-item label="生日：">
        <el-date-picker
          v-model="teacher.birthday"
          type="date"
          placeholder="请选择出生日期"
          value-format="yyyy-MM-dd"
          style="width: 100%"
        />
      </el-form-item>
      <el-form-item label="政治面貌">
        <el-input v-model="teacher.politics"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">新增教师</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      teacher: {
        tname: '',
        sex: '',
        birthday: '',
        politics: ''
      },
    }
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url: "/edu/teacher/save.do",
        method: "POST",
        data: this.teacher
      }).then(res => {
        if (res.code == 0) {
          //跳转到列表页面
          this.$router.push("/teacherlist");
        }
      })
    },
    checkPass() {
    },
    onCancel() {
      this.$message({
        message: '取消教师的新增',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line {
  text-align: center;
}
</style>
